home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / etc / mvdir.z / mvdir
Text File  |  1992-04-03  |  1KB  |  76 lines

  1. #! /bin/sh
  2. #    Copyright (c) 1984 AT&T
  3. #      All Rights Reserved
  4.  
  5. #    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
  6. #    The copyright notice above does not evidence any
  7. #    actual or intended publication of such source code.
  8.  
  9. # #ident    "@(#)mvdir:mvdir.sh    1.3"
  10. #ident "$Revision: 1.4 $"
  11. if [ $# != 2 ]
  12. then
  13.   echo "Usage: mvdir fromdir newname" 
  14.   exit 2
  15. fi
  16. if [ $1 = . ]
  17. then
  18.     echo "mvdir: cannot move `.'"
  19.     exit 2
  20. fi
  21. f=`basename $1`
  22. t=$2
  23. if [ -d $t ]
  24. then
  25.     t=$t/$f
  26. fi
  27. if [ -f $t  -o -d $t ]
  28. then
  29.   echo $t exists
  30.   exit 1
  31. fi
  32. if [  ! -d $1 ]
  33. then
  34.   echo $1 must be a directory
  35.   exit 1
  36. fi
  37.  
  38. # *** common path tests: The full path name for $1 must not
  39. # ***              be an anchored substring of the full
  40. # ***             path name for $2
  41.  
  42. here=`pwd`
  43. cd $1
  44. from=`pwd`
  45. lfrom=`expr $from : $from`
  46.  
  47. cd $here
  48. mkdir $t        # see if we can create the directory
  49. if [ $? != 0 ]
  50. then
  51.     exit
  52. fi
  53. cd $t
  54. to=`pwd`
  55. cd $here
  56. rmdir $t
  57.  
  58. a=`expr $to : $from`
  59. if [ $a = $lfrom ]
  60. then
  61.   echo arguments have common path
  62.   exit 1
  63. fi
  64. # ***
  65.  
  66. T=`expr $t : '\(.*\)/' \| .`
  67. if /etc/link $1 $t ; then
  68.     :
  69. else
  70.     echo "Cannot link to" $t 
  71.     exit 2
  72. fi
  73. /etc/unlink $1
  74. /etc/unlink $t/..
  75. /etc/link $T $t/..
  76.